// pages/release/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    starttime: '12:00',
    endtime:"12:00",
    date: '2021年05月25日',
    riderCommentList: [{
      value: '发送全员',
      selected: false,
      title: '发送全员'
     }, {
      value: '仅发送给团队管理层',
      selected: false,
       title: '仅发送给团队管理层'
     }, {
      value: '仅发送至团队成员',
      selected: false,
       title: '仅发送至团队成员'
     }, {
      value: '发送投票',
      selected: false,
       title: '发送投票'
     }, {
      value: '发送签到',
      selected: false,
       title: '发送签到'
     }],
     group:[],
     ID:
      {
        Name: "",
        StartTime: "",
        EndTime: "",
        Week: "",
        Date: "",
        DateAdd: 0,
        Kind: 2,
        room: "",
        StudentID: ""
      },
      MeetingName:"",
      GroupID:""
  },

  onLoad:function (options) {
    let that =this;
    let group = wx.getStorageSync('group')
    let thisteamName = wx.getStorageSync('selectTeamName')
    console.log(group)
    for (let i = 0; i < group.length; i++) {
      if (group[i].GroupID.GroupName==thisteamName) {
        that.setData({
          GroupID:group[i].GroupID.GroupID
        })
      }
      
    }
  },

  getMeetName:function (e) {
    let StudentID = wx.getStorageSync('StudentID')
    let Week = wx.getStorageSync('week')
    this.setData({
      MeetingName:e.detail.value,
      ['ID.Name']:e.detail.value,
      ['ID.StudentID']:StudentID,
      ['ID.Week']:Week
    })
  },

  checkboxChange(e) {
    console.log('checkboxChange e:', e);
    let string = "riderCommentList[" + e.target.dataset.index + "].selected"
    this.setData({
     [string]: !this.data.riderCommentList[e.target.dataset.index].selected
    })
    let detailValue = this.data.riderCommentList.filter(it => it.selected).map(it => it.value)
    console.log('所有选中的值为：', detailValue)
   },
  bindDateChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      date: e.detail.value,
      ['ID.Date']:e.detail.value,
    })
  },

  AddMeetLocate:function (e) {
    // let group = wx.getStorageSync('group')
    this.setData({
      ['ID.room']:e.detail.value,
    })
  },
  bindTimestartChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      starttime: e.detail.value,
      ['ID.StartTime']: e.detail.value
    })
  },
  bindTimeendChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      endtime: e.detail.value,
      ['ID.EndTime']: e.detail.value
    })
  },
  //获取输入
  toLookInfo: function (e) {
    wx.redirectTo({
      url: '../../pages/lookINfo/lookInfo'
    })
  },
  // 发布按钮事件
  confirm: function (e) {
    var that = this;
    console.log(e);
    wx.showModal({
      title: '提示',
      content: '确认发送此日程吗?',
      success: function (res) {
        if (res.confirm) {
          wx.request({
            url:'http://172.17.60.141/Forms/Meetings/', 
            data: {
              ID:that.data.ID,
              MeetingName:that.data.MeetingName,
              GroupID:that.data.GroupID
            },
            method: 'POST',
            // header: {}, // 设置请求的 header 默认是application/json
            success: function (res) {
                console.log("成功")
            //拿到该商品详情对应的商品id，再调用getProdutInfo方法
            }
          })
          var FriendId = e.currentTarget.dataset.friendid
          wx.redirectTo({
            url: '../../pages/history/index'
          })
        } else if (res.cancel) {
          console.log('用户点击取消');
        }
      }
    })
  }
})